ImagXpress 13 for .NET - User Guide > How To > Free the Control's Resources |
Because ImagXpress® encapsulates unmanaged resources, the Dispose method must be called for each instance of each component, to allow the release of all resources. A recommended approach is to dispose these objects when their container is disposed. To do this, call the Dispose method from the container. Since some of the components within the ImagXpress Product Family have dependencies on the ImagXpress component, you should dispose the ImagXpress objects last.
C# Example |
Copy Code
|
---|---|
// This code demonstrates that in all .NET Windows Forms applications, you will find a generated call to Dispose, which can be modified as follows: protected override void Dispose (bool disposing) { if (disposing) { if (components != NULL) { components.Dispose(); } // added for ImagXpress, // dispose the ImagXpress control last. // The application developer is not required to call Dispose at this location. The Developer can make the call to clean up these resources at any time during the container's lifetime. PrintPRO.Dispose(); TwainPRO.Dispose(); NotateXpress.Dispose(); ThumbnailXpress.Dispose(); ImageXView.Dispose(); Processor.Dispose(); ImagXpress.Dispose(); } base.Disposing(disposing); } |
In addition, any objects that are created dynamically at run time (e.g. ImageX), must call their Dispose method to allow resources to be released when the object is no longer needed. |
C# Example |
Copy Code
|
---|---|
// When ColorSeparation is called with handles specified for each of the color planes,
// call ImageX.DisposeHbitmap to release the resources associated with the handles after use.
// When the ImageX object is not longer needed, Dispose it.
|